<?php
session_start();

if(!isset($_SESSION['id'])){
	header('Location:login.php');
}
$username=$_SESSION['username'];
$connetc=mysql_connect("localhost","root","");
mysql_select_db("shenji",$connetc);
mysql_query("set names utf8");
$sql4="select * from user where username='$username'";

$result4=mysql_query($sql4);
$row4=mysql_num_rows($result4);


if($row4==0){
	echo "<script>alert('用户不存在，请重新登录！');top.location.href='./login.php'</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery-1.6.3.min.js"></script>
</head>

<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">升级管理</a></li>
    <li><a href="#">升级方式</a></li>			
    </ul>
    </div>
	
    <div class="formbody">
    <div class="formtitle"><span>基本信息</span></div>
	<?php
     $way=file_get_contents("/var/www/html/upload/about_url.conf");
	?>
    <label>配置升级服务器地址:</label><br/><br/>
	<input type="test" name="url" id="url" class="dfinput" value="<?php echo $way;?>"/>
	<input type="button" value="确定" class="btn" onclick="tijiao_url();"><br/><br/>
	
	<form action="about_way_commit.php" method="post" enctype="multipart/form-data">
	<label>选择升级方式:</label><br/><br/>
	<?php
	 $array=array();
	 $handle = fopen("about_shenji.conf", "r");
	 while (!feof ($handle)){
		 $buffer  = fgets($handle);
		 array_push($array,$buffer);
	 }
	#得到配置文件中的信息
	$get_way=$array[0];
	$rel_way=substr($get_way,4);
	$rel_way1=intval($rel_way);
	?>
	<input type="radio" name="way" value="0" <?php if($rel_way1==0){echo "checked=checked";} ?> onclick="auto();"/>自动升级
	<input type="radio" name="way" value="1" <?php if($rel_way1==1){ echo "checked=chjecked";}?>  onclick="shoudong();"/>手动升级
	<div style="margin-top:20px;display:none;" id="div_file">
	上传升级包<input type="file" name="file" id="file"/>	
	</div><br/>
	<input type="submit" value="提交" class="btn" style="margin-top:20px;"/>
	</form>
    </div>
	
</body>

</html>

<script>
$(document).ready(function(){
	 var radio_value=$('input:radio[name="way"]:checked').val();
	 if(radio_value==1){
		 $("#div_file").show();
	 }
})

 function auto(){
    $("#div_file").hide();
 }
	
 function shoudong(){
	$("#div_file").show();
 }
 
 function tijiao_url(){
	 var url=$("#url").val();
	 $.post("about_url_commit.php",{url:url},function(data){
			alert("操作成功");
	 })
	 
 }
 
/*  function tiaojiao_way(){
	 var name=$("#file").val(); 
	 var radio_value=$('input:radio[name="way"]:checked').val();
		
	 if(radio_value==0){
		 return true;
	 } 
	if(radio_value==1){
 		if(name.length==0){
			  alert("请输入文件"); 
			  return false;			
		}else{
				
			  return true;
			  
		 } 
		
	} 
	  
 } */
 
</script>




